<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="UTF-8">
    <title>商品详情</title>

    <link rel="stylesheet" type="text/css" href="/plugins/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/css/nav.css">
    <link rel="stylesheet" type="text/css" href="/plugins/layui/css/layui.css">
</head>
<body>

<%@include file="../common/nav.jsp"%>

<input type="hidden" value="${user.userId}" id="userId_hidden">
<input type="hidden" value="${goods.goodsName}" id="goodsName_hidden">
<input type="hidden" value="${goods.id}" id="goodsId_hidden">
<input type="hidden" value="${goods.goodsPrice}" id="goodsPrice_hidden">
<input type="hidden" value="${goods.goodsImg}" id="goodsImg_hidden">
<input type="hidden" value="${goods.goodsRemark}" id="goodsRemark_hidden">

<div class="container">
    <div class="row">
        <div class="col-md-3"></div>

        <div class="col-md-9">
            <form class="form-horizontal" role="form">
                <input type="hidden" value="${goods.id}" name="id">

                <div class="form-group">
                    <label class="col-sm-1 control-label"></label>
                    <div class="col-sm-11">
                        <img src="/imgs/${goods.goodsImg}" style="width: 400px;height: 400px">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">商品名：</label>
                    <div class="col-sm-9">
                        <label class="col-sm-4 control-label" style="padding-left: -100px">${goods.goodsName}</label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">价格：</label>
                    <div class="col-sm-9">
                        <label class="col-sm-4 control-label" style="padding-left: -100px">${goods.goodsPrice}</label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">介绍：</label>
                    <div class="col-sm-9">
                        <label class="col-sm-4 control-label" style="padding-left: -100px">${goods.goodsRemark}</label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-10">
                        <label class="col-sm-2.5 control-label" style="padding-left: -100px">
                            <button type="button" class="btn btn-primary btn-group-lg" onclick="addshangpin(${goods.id})"
                            <%--                                        onclick="addproduct()"--%>
                            >加入购物车</button>
                        </label>
                        <label class="col-sm-3 control-label" style="padding-left: -100px">
                            <button type="button" class="btn btn-primary btn-group-lg" onclick="exit()"
                            <%--                                        onclick="addproduct()"--%>
                            >返回</button>

                        </label>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="/plugins/jquery/jquery.min.js"></script>
<script src="/plugins/bootstrap/js/bootstrap.js"></script>
<script src="/plugins/layui/layui.js"></script>

<script>
    function addshangpin(goodsId){


        $.post("/product/insert2",{goodsId:goodsId},function (result) {
            alert(result.msg);
        });
    }
</script>

<script>
    function exit(){
        window.location = "/shoucang/index";
    }
</script>


<%--    <script>--%>
<%--        function addproduct(){--%>
<%--            let userid = $("#userid_hidden").val();--%>
<%--            let productname =$("#productname_hidden").val();--%>
<%--            let productid = $("#productid_hidden").val();--%>
<%--            let price =$("#price_hidden").val();--%>
<%--            let number = $("#J_IptAmount").val();--%>
<%--            let imgurl = $("#imgurl_hidden").val();--%>

<%--            if (userid == "") {--%>
<%--                window.location = "/mvc/user/login";--%>
<%--            }else {--%>
<%--                $.post("/mvc/shoppingcart/addcart",{userid:userid,productid:productid,productname:productname,price:price,number:number,imgurl:imgurl},function (data){--%>
<%--                    layui.use('layer', function(){--%>
<%--                        var layer = layui.layer;--%>
<%--                        layer.msg(data.msg,{icon:6})--%>
<%--                    });--%>
<%--                })--%>
<%--            }--%>
<%--        }--%>

<%--    </script>--%>
</body>
</html>